package com.guashu.springbootdistributedid.demo;

import java.io.*;
import java.util.Base64;

public class Base64ToImageConverter {

    public static void main(String[] args) {
        String inputFilePath = "E:\\国银租赁\\观微文档\\out.txt";
        String outputImagePath = "E:\\国银租赁\\观微文档\\output.png";

        try {
            BufferedReader reader = new BufferedReader(new FileReader(inputFilePath));
            StringBuilder base64Image = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                base64Image.append(line);
            }

            byte[] imageBytes = Base64.getDecoder().decode(base64Image.toString());

            FileOutputStream fos = new FileOutputStream(outputImagePath);
            fos.write(imageBytes);
            fos.close();

            System.out.println("Image has been successfully written to output.png.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
